package com.xbongbong.paas.script.enums;

import com.xbongbong.pro.enums.CommunicatePlanNotifyTypeEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import com.xbongbong.saas.enums.business.ClueEnum;
import com.xbongbong.saas.enums.business.CommunicatePlanEnum;
import com.xbongbong.saas.enums.business.CustomerCommunicateEnum;
import com.xbongbong.saas.enums.business.QuotationEnum;
import com.xbongbong.saas.enums.dictionary.ClueStatusEnum;
import com.xbongbong.saas.enums.dictionary.QuotationStatusEnum;
import lombok.Getter;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;

/**
 * @author guohui.zhang
 * @Title:
 * @date 2021/3/1614:25
 */
@Getter
public enum I18nItemUpdateEnum {
    // QUOTATION_1(XbbRefTypeEnum.QUOTATION.getCode(), QuotationEnum.STATUS.getAttr(), QuotationStatusEnum.IN_QUOTATION.getCode(), "Quotation"),
    // QUOTATION_2(XbbRefTypeEnum.QUOTATION.getCode(), QuotationEnum.STATUS.getAttr(), QuotationStatusEnum.INVALID.getCode(), "Invalid"),
    // 报价单
    QUOTATION_3(XbbRefTypeEnum.QUOTATION.getCode(), QuotationEnum.STATUS.getAttr(), QuotationStatusEnum.CREATED.getCode(), "Contract order generated"),
    // 访客计划
    COMMUNICATE_PLAN_1(XbbRefTypeEnum.COMMUNICATE_PLAN.getCode(), CommunicatePlanEnum.NOTIFY_TYPE.getAttr(), CommunicatePlanNotifyTypeEnum.NO_NOTIFY.getCode().toString(), "No reminder"),
    COMMUNICATE_PLAN_2(XbbRefTypeEnum.COMMUNICATE_PLAN.getCode(), CommunicatePlanEnum.NOTIFY_TYPE.getAttr(), CommunicatePlanNotifyTypeEnum.ADVANCE_ONE_QUARTER_HOUR.getCode().toString(), "15 minutes in advance"),
    COMMUNICATE_PLAN_3(XbbRefTypeEnum.COMMUNICATE_PLAN.getCode(), CommunicatePlanEnum.NOTIFY_TYPE.getAttr(), CommunicatePlanNotifyTypeEnum.ADVANCE_ONE_HOUR.getCode().toString(), "1 hour in advance"),
    COMMUNICATE_PLAN_4(XbbRefTypeEnum.COMMUNICATE_PLAN.getCode(), CommunicatePlanEnum.NOTIFY_TYPE.getAttr(), CommunicatePlanNotifyTypeEnum.ADVANCE_ONE_DAY.getCode().toString(), "1 days in advance"),
    COMMUNICATE_PLAN_5(XbbRefTypeEnum.COMMUNICATE_PLAN.getCode(), CommunicatePlanEnum.NOTIFY_TYPE.getAttr(), CommunicatePlanNotifyTypeEnum.ADVANCE_THREE_DAY.getCode().toString(), "3 days in advance"),
    COMMUNICATE_PLAN_6(XbbRefTypeEnum.COMMUNICATE_PLAN.getCode(), CommunicatePlanEnum.NOTIFY_TYPE.getAttr(), CommunicatePlanNotifyTypeEnum.ADVANCE_ONE_WEEK.getCode().toString(), "1 weeks in advance"),
    COMMUNICATE_PLAN_7(XbbRefTypeEnum.COMMUNICATE_PLAN.getCode(), CommunicatePlanEnum.NOTIFY_TYPE.getAttr(), CommunicatePlanNotifyTypeEnum.CUSTOM_TIME.getCode().toString(), "Custom time"),
    // 跟进记录
    CUSTOMER_COMMUNICATION_BUSINESS_1(XbbRefTypeEnum.CUSTOMER_COMMUNICATE.getCode(), CustomerCommunicateEnum.COMMUNICATE_BUSINESS.getAttr(), "301", "Sales opportunity"),
    CUSTOMER_COMMUNICATION_BUSINESS_2(XbbRefTypeEnum.CUSTOMER_COMMUNICATE.getCode(), CustomerCommunicateEnum.COMMUNICATE_BUSINESS.getAttr(), "201", "Contract order"),
    CUSTOMER_COMMUNICATION_BUSINESS_3(XbbRefTypeEnum.CUSTOMER_COMMUNICATE.getCode(), CustomerCommunicateEnum.COMMUNICATE_BUSINESS.getAttr(), "4700", "Quotation"),
    // 线索
    CLUE_STATUS_1(XbbRefTypeEnum.CLUE.getCode(), ClueEnum.CLUE_STATUS.getAttr(), ClueStatusEnum.PENDING.getCode(), "pending"),
    CLUE_STATUS_2(XbbRefTypeEnum.CLUE.getCode(), ClueEnum.CLUE_STATUS.getAttr(), ClueStatusEnum.FOLLOWING_UP.getCode(), "following up"),
    CLUE_STATUS_3(XbbRefTypeEnum.CLUE.getCode(), ClueEnum.CLUE_STATUS.getAttr(), ClueStatusEnum.TRANSFORMED.getCode(), "transformed"),
    CLUE_STATUS_4(XbbRefTypeEnum.CLUE.getCode(), ClueEnum.CLUE_STATUS.getAttr(), ClueStatusEnum.INVALID.getCode(), "invalid"),








    ;
    /**
     * 业务类型
     */
    private Integer businessType;
    /**
     * 子段attr
     */
    private String attr;
    /**
     * code
     */
    private String code;
    /**
     * nameEn
     */
    private String nameEn;

    I18nItemUpdateEnum(Integer businessType, String attr, String code, String nameEn) {
        this.businessType = businessType;
        this.attr = attr;
        this.code = code;
        this.nameEn = nameEn;
    }

    public static List<I18nItemUpdateEnum> getByBusinessType(int businessType) {
        List<I18nItemUpdateEnum> fieldEnums = new ArrayList<>();
        for (I18nItemUpdateEnum anEnum : values()) {
            if (Objects.equals(businessType, anEnum.getBusinessType())) {
                fieldEnums.add(anEnum);
            }
        }
        return fieldEnums;
    }

    public static Set<String> getAttrs(int businessType) {
        Set<String> fieldEnums = new HashSet<>();
        for (I18nItemUpdateEnum anEnum : values()) {
            if (Objects.equals(businessType, anEnum.getBusinessType())) {
                fieldEnums.add(anEnum.getAttr());
            }
        }
        return fieldEnums;
    }


}
